<template>
  <ZoneModal v-if="visible" v-model:visible="visible" @save="handleSava" />
</template>
<script setup>
import ZoneModal from './publish-zone.vue'
import { createZone } from '@/api/zone'
import { useVModel } from '@vueuse/core'
import { Message } from '@arco-design/web-vue'
import { useUserStore } from '@/store'
const { userInfo } = useUserStore()
const props = defineProps(['visible'])
const emits = defineEmits(['update:visible', 'ok'])
const visible = useVModel(props, 'visible', emits)

const handleSava = (data) => {
  createZone(data).then((res) => {
    Message.success('发布成功')
    emits('ok', {
      ...data,
      ...userInfo,
      id: res,
      created_at: new Date().toLocaleString()
    })
  })
}
</script>
<style lang="less" scoped></style>
